[mirrors]
http://ftp.gnu.org/gnu/coreutils/coreutils-8.25.tar.xz

[vars]
filesize=5725008
sha512=571f95d44987d373081ed4c6ac82155ad3dcd95621d7b1a7163597e80ecbbafef2cd74b2ef594587a443a1a4355083879f898a286bb0230c48112d43d076ccd6
desc="GNU core utilities"

[deps]
busybox

[deps.host]
dynamic-toolchain

[build]
#note, 8.24 onwards supports progress-bar for dd.
#disables symlinking after install, as it is done below...
butch_do_relocate=false

#much of this comes from the full coreutiles recipe...
# by default gnulib builds 230 of 389 C-files.
GNULIB_CPPFLAGS=$("$K"/gnulibfix lib)
dir=$PWD
[ -n "$CROSS_COMPILE" ] && xconfflags="--host=$($CC -dumpmachine)"

#static pkgs are so big! have removed "-static" from LDFLAGS...
FORCE_UNSAFE_CONFIGURE=1 LDFLAGS="$optldflags" \
  CFLAGS="-D_GNU_SOURCE -I $dir $GNULIB_CPPFLAGS" \
    ./configure -C --prefix="$butch_prefix" \
      gl_cv_func_working_mktime=yes gl_cv_func_linkat_follow=yes gl_cv_func_mknod_works=yes \
      gl_cv_func_getgroups_works=yes $xconfflags

make V=1 -j$MAKE_THREADS || exit 1

#this is a cutdown installation, for quirky linux (need to replace some busybox applets)...
#make DESTDIR="$butch_install_dir" install
[ -d "$R"/opt/coreutils ] && rm -rf "$R"/opt/coreutils
mkdir -p "$R"/opt/coreutils/bin
for APROG in cat chmod cksum comm cp cut date dd dirname du expand fold ginstall head install join ln ls md5sum mv od paste pr readlink rm rmdir seq sleep sort split stat tac test touch uname uniq wc
do
 [ ! -e src/$APROG ] && continue
 busybox cp -a src/$APROG "$R"/opt/coreutils/bin/
 #replace busybox applets...
 busybox ln -snf ../opt/coreutils/bin/$APROG "$R"/bin/$APROG
done
[ -f "$R"/opt/coreutils/bin/ginstall ] && [ ! -e "$R"/opt/coreutils/bin/install ] && busybox ln -snf ../opt/coreutils/bin/ginstall "$R"/bin/install
#leave the busybox df in place...
if [ -f src/df ];then
 busybox cp -a src/df "$R"/opt/coreutils/bin/
 busybox ln -snf ../opt/coreutils/bin/df "$R"/bin/df-FULL
fi

